package org.wendu.wdoa.common;

import lombok.Getter;

@Getter
public class Result {

    public static final int CODE_OK = 200;//成功
    public static final int CODE_ERR_BUSINESS = 500;//业务失败
    public static final int CODE_ERR_UNLOGINED = 520;//未登录
    public static final int CODE_ERR_SYS = 530;//系统错误

    public static Result OK(){
        return new Result(true,CODE_OK, null, null);
    }

    public static Result OK(String message){
        return new Result(true,CODE_OK, message, null);
    }
    public static Result OK(String message,Object data){
        return new Result(true,CODE_OK, message, data);
    }
    public static Result OK(Object data){
        return new Result(true,CODE_OK, null, data);
    }

    public static Result err(int errCode,String message){
        return new Result(false, errCode, message, null);
    }

    public static Result err(int errCode,String message,Object data){
        return new Result(false, errCode, message, data);
    }

    private boolean success;
    private int code;
    private String message;
    private Object data;

    private Result(boolean success, int code, String message, Object data) {
        this.success = success;
        this.code = code;
        this.message = message;
        this.data = data;
    }


}
